from microbit import *
def _dat(L1, L2, R1, R2):
    pin0.write_analog(L1)
    pin16.write_analog(L2)
    pin8.write_analog(R1)
    pin12.write_analog(R2)  
    
def qian():
    _dat(180, 0, 0, 180)
    
def hou():
    _dat(0, 200, 0, 200)

def you():
    _dat(0, 200, 0, 550)
    
def zuo():
    _dat(550, 0, 200, 0)
    
def ting():
    _dat(0, 0, 0, 0)
    
while True:
    chao = pin2.read_digital()

    if chao == 1:
        qian()
        sleep(100)
        continue
        
    if chao == 0:
        ting()
        sleep(100)
        if chao == 0:
            pass
            break
            
while True:   
    zuo()
    sleep(900)
    qian()
    sleep(100)
    break
        
while True: 
    she = pin1.read_digital()
    
    if she == 1:
        qian()
        sleep(100)
        continue
        
    if she == 0:
        qian()
        sleep(300)
        ting()
        sleep(200)
        zuo()
        sleep(900)
        ting()
        sleep(300)
        hou()
        sleep(2000)
        ting()
        sleep(5000)
        if she == 0:
            pass
            break      #
                                   

while True:
    chao = pin2.read_digital()

    if chao == 1:
        qian()
        sleep(100)
        continue
        
    if chao == 0:
        ting()
        sleep(100)
        if chao == 0:
            qian()
            sleep(400)
            zuo()
            sleep(850)
            pass
            break 


while True:
    chao = pin2.read_digital()
    if chao == 1:
        qian()
        sleep(100)
        continue
    if chao == 0:
        ting()
        sleep(100)
        qian()
        sleep(200)
        you()
        sleep(900)
        ting()
        sleep(200)
        qian()
        sleep(5000)
        if chao == 0:
            ting()
            break
            
    
        
            
